package com.study.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Scala04_RDD_Operator_Transform_1 {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(conf)

    // TODO 算子 - 转换 - 扁平映射:flatMap
    val rdd = sc.makeRDD(
      List(List(1, 2), 3, List(4, 5))
    )

    val rdd1 = rdd.flatMap {
      case list: List[_] => list
      case other => List(other)
    }
    rdd1.collect().foreach(println)
    /*
    1
    2
    3
    4
    5
     */
    sc.stop()



  }

}
